package bean;

/**
 * @author Ajie
 * @date 2023/2/22
 * @function
 */
public class BeanUtilsTest {

    public static void main(String[] args) {
        Person person = new Person("Alice", 20, "female");
        Employee employee = new Employee("Bob", 30, "manager");

        BeanUtils.copyFields(person, employee);

        System.out.println(person.toString()); // Alice
        System.out.println(employee.toString());  // 20

        System.out.println("BeanUtilsTest:main:over" );
    }

    public static class Person {
        private String name;
        private int age;
        private String gender;

        public Person(String name, int age, String gender) {
            this.name = name;
            this.age = age;
            this.gender = gender;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    ", gender='" + gender + '\'' +
                    '}';
        }
    }

    public static class Employee {
        private String name;
        private int age;
        private String position;

        public Employee(String name, int age, String position) {
            this.name = name;
            this.age = age;
            this.position = position;
        }


        @Override
        public String toString() {
            return "Employee{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    ", position='" + position + '\'' +
                    '}';
        }
    }

}
